package com.autumn.zero.workflow.listeners;

import java.util.ArrayList;
import java.util.List;

/**
 * 进程监听通知管理
 * 
 * @author 杨昌国 2019-02-20 14:15:40
 */
public class ProcessListenerNotifyManager {
	private List<IProcessListenerNotify> listeners = new ArrayList<>();

	/**
	 * 初始化
	 */
	public void initialize() {
		synchronized (this) {
			listeners.clear();
		}
	}

	/**
	 * 注册
	 * 
	 * @param notify 通知
	 */
	public void register(IProcessListenerNotify notify) {
		synchronized (this) {
			listeners.add(notify);
		}
	}

	/**
	 * 转为数组
	 * 
	 * @return
	 */
	public IProcessListenerNotify[] toNotifys() {
		synchronized (this) {
			IProcessListenerNotify[] notifys = new IProcessListenerNotify[listeners.size()];
			return listeners.toArray(notifys);
		}
	}

}
